package com.pay.ioopos;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import pl.droidsonroids.gif.GifDrawable;
import pl.droidsonroids.gif.GifImageView;

public class Loading extends Dialog {

    private GifDrawable gifDrawable;

    public Loading(Context context) {
        super(context, R.style.LoadingDialogStyle);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setCancelable(true);
        setCanceledOnTouchOutside(false);
        setContentView(R.layout.loading);
        GifImageView gifImageView = findViewById(R.id.loading_gif);
        gifDrawable = (GifDrawable) gifImageView.getDrawable();


        Window window = getWindow();
        window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        window.setDimAmount(0f);
        window.setGravity(Gravity.CENTER);
        WindowManager.LayoutParams params = window.getAttributes();
        params.width = WindowManager.LayoutParams.WRAP_CONTENT;
        params.height = WindowManager.LayoutParams.WRAP_CONTENT;
        params.systemUiVisibility = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION|View.SYSTEM_UI_FLAG_IMMERSIVE;//|View.SYSTEM_UI_FLAG_FULLSCREEN
        window.setAttributes(params);

    }

    @Override
    protected void onStart() {
        super.onStart();
        gifDrawable.start();
    }

    @Override
    protected void onStop() {
        super.onStop();
        gifDrawable.stop();
    }


}
